package com.prs.crm.dao.warning.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.warning.WarnContentDao;
import com.prs.crm.domain.warning.WarnContent;

/**
 * @author JohnLan
 * @time：2012-11-21 
 * @version 1.0
 * 类说明
 */

public class WarnContentDaoImpl extends BaseDaoImpl<WarnContent> implements
		WarnContentDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<WarnContent> getWarnContent() {
		return  (List<WarnContent>) this.getHibernateTemplate().execute(
				new HibernateCallback() {
					public Object doInHibernate(Session session)
							throws HibernateException {
						Criteria criteria = session.createCriteria(WarnContent.class);
						List<WarnContent> slist=criteria.list();
						List<WarnContent> res=new ArrayList<WarnContent>();
						if(criteria.list()!=null || criteria.list().size()>0)
						{
						for(WarnContent b:slist)
						{
							String bsty=b.getWarnstyl();	
						 if(res==null)
						 {
							 res.add(b); 
						 }else{
							 int i=0;
							 for(WarnContent bb:res)
							 {
								 String bsty1=bb.getWarnstyl();
								 if(bsty1.equals(bsty))
								 {
									i++; 
								 }
							 }
							 if(i==0)
							 {
								 res.add(b);  
							 }
							 
						 }
						}
						}
						
						return res;
					}
				});
	}

}
